home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / klax.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  13KB  |  441 lines

  1. /***************************************************************************
  2.  
  3. Klax Memory Map
  4. ---------------
  5.  
  6. KLAX 68000 MEMORY MAP
  7.  
  8. Program ROM             000000-05FFFF   R    D[15:0]
  9. Program ROM slapstic    058000-05FFFF   R    D[15:0]   (not used!)
  10.  
  11. EEPROM                  0E0001-0E0FFF  R/W   D[7:0]    (odd bytes only)
  12. UNLOCK EEPROM           1Fxxxx          W
  13. Watch Dog               2E0000          W    xx        (128 msec. timeout)
  14.  
  15. Color RAM Motion Object 3E0000-3E03FE  R/W   D[15:8]
  16. Color RAM Playfield     3E0400-3E07FE  R/W   D[15:8]
  17.  
  18. Playfield Picture RAM   3F0000-3F0EFF  R/W   D[15:0]
  19. MOB config              3F0F00-3F0F70  R/W   D[15:0]
  20. SLIP pointers           3F0F80-3F0FFF  R/W   M.O. link pointers
  21. Playfield palette AM    3F1000-3F1FFF  R/W   D[11:8]
  22. Motion Object RAM       3F2000-3F27FF  R/W   D[15:0]
  23. (Link, Picture, H-Pos, V-Pos, Link... etc.)
  24. Working RAM             3F2800-3F3FFF  R/W   D[15:0]
  25.  
  26. Player 1 Input (left)   260000          R    D[15:12],D8 Active lo
  27. Player 2 Input (right)  260002          R    D[15:12],D8 Active lo
  28.       D8:    flip
  29.       D12:   right
  30.       D13:   left
  31.       D14:   down
  32.       D15:   up
  33.  
  34. Status inputs           260000          R    D11,D1,D0
  35.       D0:    coin 1 (left) Active lo
  36.       D1:    coin 2 (right) Active lo
  37.       D11:   self-test Active lo
  38.  
  39. LATCH                   260000          W    D[12:8]
  40.       D8:    ADPCM chip reset (active lo)
  41.       D9:    Spare
  42.       D10:   Coin Counter 2 (right)
  43.       D11:   Coin Counter 1 (left)
  44.       D12:   Spare
  45.       D13:   Color RAM bank select
  46.   NOTE: RESET clears this latch
  47.  
  48. 4ms Interrupt ack.      360000          W    xx
  49.  
  50. ADPCM chip              270000         R/W   D[7:0]
  51.  
  52. ****************************************************************************/
  53.  
  54.  
  55.  
  56. #include "driver.h"
  57. #include "machine/atarigen.h"
  58. #include "vidhrdw/generic.h"
  59.  
  60.  
  61. WRITE_HANDLER( klax_playfieldram_w );
  62. WRITE_HANDLER( klax_latch_w );
  63.  
  64. int klax_vh_start(void);
  65. void klax_vh_stop(void);
  66. void klax_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  67.  
  68. void klax_scanline_update(int scanline);
  69.  
  70.  
  71.  
  72. /*************************************
  73.  *
  74.  *    Interrupt handling
  75.  *
  76.  *************************************/
  77.  
  78. static void update_interrupts(void)
  79. {
  80.     int newstate = 0;
  81.  
  82.     if (atarigen_video_int_state || atarigen_scanline_int_state)
  83.         newstate = 4;
  84.  
  85.     if (newstate)
  86.         cpu_set_irq_line(0, newstate, ASSERT_LINE);
  87.     else
  88.         cpu_set_irq_line(0, 7, CLEAR_LINE);
  89. }
  90.  
  91.  
  92. static void scanline_update(int scanline)
  93. {
  94.     /* update the video */
  95.     klax_scanline_update(scanline);
  96.  
  97.     /* generate 32V signals */
  98.     if (scanline % 64 == 0 && !(readinputport(0) & 0x800))
  99.         atarigen_scanline_int_gen();
  100. }
  101.  
  102.  
  103. static WRITE_HANDLER( interrupt_ack_w )
  104. {
  105.     atarigen_scanline_int_ack_w(offset, data);
  106.     atarigen_video_int_ack_w(offset, data);
  107. }
  108.  
  109.  
  110.  
  111. /*************************************
  112.  *
  113.  *    Initialization
  114.  *
  115.  *************************************/
  116.  
  117. static void init_machine(void)
  118. {
  119.     atarigen_eeprom_reset();
  120.     atarigen_interrupt_reset(update_interrupts);
  121.     atarigen_scanline_timer_reset(scanline_update, 8);
  122. }
  123.  
  124.  
  125.  
  126. /*************************************
  127.  *
  128.  *    Sound I/O
  129.  *
  130.  *************************************/
  131.  
  132. static READ_HANDLER( adpcm_r )
  133. {
  134.     return OKIM6295_status_0_r(offset) | 0xff00;
  135. }
  136.  
  137.  
  138. static WRITE_HANDLER( adpcm_w )
  139. {
  140.     if (!(data & 0x00ff0000))
  141.         OKIM6295_data_0_w(offset, data & 0xff);
  142. }
  143.  
  144.  
  145.  
  146. /*************************************
  147.  *
  148.  *    Main CPU memory handlers
  149.  *
  150.  *************************************/
  151.  
  152. static struct MemoryReadAddress readmem[] =
  153. {
  154.     { 0x000000, 0x03ffff, MRA_ROM },
  155.     { 0x0e0000, 0x0e0fff, atarigen_eeprom_r },
  156.     { 0x260000, 0x260001, input_port_0_r },
  157.     { 0x260002, 0x260003, input_port_1_r },
  158.     { 0x270000, 0x270001, adpcm_r },
  159.     { 0x3e0000, 0x3e07ff, MRA_BANK1 },
  160.     { 0x3f0000, 0x3f1fff, MRA_BANK2 },
  161.     { 0x3f2000, 0x3f27ff, MRA_BANK3 },
  162.     { 0x3f2800, 0x3f3fff, MRA_BANK4 },
  163.     { -1 }  /* end of table */
  164. };
  165.  
  166.  
  167. static struct MemoryWriteAddress writemem[] =
  168. {
  169.     { 0x000000, 0x03ffff, MWA_ROM },
  170.     { 0x0e0000, 0x0e0fff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
  171.     { 0x1f0000, 0x1fffff, atarigen_eeprom_enable_w },
  172.     { 0x260000, 0x260001, klax_latch_w },
  173.     { 0x270000, 0x270001, adpcm_w },
  174.     { 0x2e0000, 0x2e0001, watchdog_reset_w },
  175.     { 0x360000, 0x360001, interrupt_ack_w },
  176.     { 0x3e0000, 0x3e07ff, atarigen_expanded_666_paletteram_w, &paletteram },
  177.     { 0x3f0000, 0x3f1fff, klax_playfieldram_w, &atarigen_playfieldram, &atarigen_playfieldram_size },
  178.     { 0x3f2000, 0x3f27ff, MWA_BANK3, &atarigen_spriteram, &atarigen_spriteram_size },
  179.     { 0x3f2800, 0x3f3fff, MWA_BANK4 },
  180.     { -1 }  /* end of table */
  181. };
  182.  
  183.  
  184.  
  185. /*************************************
  186.  *
  187.  *    Port definitions
  188.  *
  189.  *************************************/
  190.  
  191. INPUT_PORTS_START( klax )
  192.     PORT_START
  193.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
  194.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
  195.     PORT_BIT( 0x00fc, IP_ACTIVE_LOW, IPT_UNUSED )
  196.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  197.     PORT_BIT( 0x0600, IP_ACTIVE_LOW, IPT_UNUSED )
  198.     PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_VBLANK )
  199.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
  200.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1 )
  201.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER1 )
  202.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER1 )
  203.  
  204.     PORT_START
  205.     PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
  206.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  207.     PORT_BIT( 0x0600, IP_ACTIVE_LOW, IPT_UNUSED )
  208.     PORT_SERVICE( 0x0800, IP_ACTIVE_LOW )
  209.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
  210.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2 )
  211.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2 )
  212.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2 )
  213. INPUT_PORTS_END
  214.  
  215.  
  216.  
  217. /*************************************
  218.  *
  219.  *    Graphics definitions
  220.  *
  221.  *************************************/
  222.  
  223. static struct GfxLayout pflayout =
  224. {
  225.     8,8,    /* 8*8 sprites */
  226.     8192,    /* 8192 of them */
  227.     4,        /* 4 bits per pixel */
  228.     { 0, 1, 2, 3 },
  229.     { 0, 4, 0x20000*8+0, 0x20000*8+4, 8, 12, 0x20000*8+8, 0x20000*8+12 },
  230.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  231.     16*8    /* every sprite takes 16 consecutive bytes */
  232. };
  233.  
  234.  
  235. static struct GfxLayout molayout =
  236. {
  237.     8,8,    /* 8*8 sprites */
  238.     4096,    /* 4096 of them */
  239.     4,        /* 4 bits per pixel */
  240.     { 0, 1, 2, 3 },
  241.     { 0, 4, 0x10000*8+0, 0x10000*8+4, 8, 12, 0x10000*8+8, 0x10000*8+12 },
  242.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  243.     16*8    /* every sprite takes 16 consecutive bytes */
  244. };
  245.  
  246.  
  247. static struct GfxDecodeInfo gfxdecodeinfo[] =
  248. {
  249.     { REGION_GFX1, 0, &pflayout,  256, 16 },        /* sprites & playfield */
  250.     { REGION_GFX2, 0, &molayout,    0, 16 },        /* sprites & playfield */
  251.     { -1 } /* end of array */
  252. };
  253.  
  254.  
  255.  
  256. /*************************************
  257.  *
  258.  *    Sound definitions
  259.  *
  260.  *************************************/
  261.  
  262. static struct OKIM6295interface okim6295_interface =
  263. {
  264.     1,                    /* 1 chip */
  265.     { ATARI_CLOCK_14MHz/4/4/132 },
  266.     { REGION_SOUND1 },
  267.     { 100 }
  268. };
  269.  
  270.  
  271.  
  272. /*************************************
  273.  *
  274.  *    Machine driver
  275.  *
  276.  *************************************/
  277.  
  278. static struct MachineDriver machine_driver_klax =
  279. {
  280.     /* basic machine hardware */
  281.     {
  282.         {
  283.             CPU_M68000,        /* verified */
  284.             ATARI_CLOCK_14MHz/2,
  285.             readmem,writemem,0,0,
  286.             atarigen_video_int_gen,1
  287.         }
  288.     },
  289.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  290.     1,
  291.     init_machine,
  292.  
  293.     /* video hardware */
  294.     42*8, 30*8, { 0*8, 42*8-1, 0*8, 30*8-1 },
  295.     gfxdecodeinfo,
  296.     512, 512,
  297.     0,
  298.  
  299.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_SUPPORTS_DIRTY,
  300.     0,
  301.     klax_vh_start,
  302.     klax_vh_stop,
  303.     klax_vh_screenrefresh,
  304.  
  305.     /* sound hardware */
  306.     0,0,0,0,
  307.     {
  308.         {
  309.             SOUND_OKIM6295,
  310.             &okim6295_interface
  311.         }
  312.     },
  313.  
  314.     atarigen_nvram_handler
  315. };
  316.  
  317.  
  318.  
  319. /*************************************
  320.  *
  321.  *    ROM definition(s)
  322.  *
  323.  *************************************/
  324.  
  325. ROM_START( klax )
  326.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  327.     ROM_LOAD_EVEN( "136075-6.006", 0x00000, 0x10000, 0xe8991709 )
  328.     ROM_LOAD_ODD ( "136075-6.005", 0x00000, 0x10000, 0x72b8c510 )
  329.     ROM_LOAD_EVEN( "136075-6.008", 0x20000, 0x10000, 0xc7c91a9d )
  330.     ROM_LOAD_ODD ( "136075-6.007", 0x20000, 0x10000, 0xd2021a88 )
  331.  
  332.     ROM_REGION( 0x40000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  333.     ROM_LOAD( "136075-2.010", 0x00000, 0x10000, 0x15290a0d )
  334.     ROM_LOAD( "136075-2.012", 0x10000, 0x10000, 0xc0d9eb0f )
  335.     ROM_LOAD( "136075-2.009", 0x20000, 0x10000, 0x6368dbaf )
  336.     ROM_LOAD( "136075-2.011", 0x30000, 0x10000, 0xe83cca91 )
  337.  
  338.     ROM_REGION( 0x20000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  339.     ROM_LOAD( "136075-2.014", 0x00000, 0x10000, 0x5c551e92 )
  340.     ROM_LOAD( "136075-2.013", 0x10000, 0x10000, 0x36764bbc )
  341.  
  342.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM data */
  343.     ROM_LOAD( "136075-1.015", 0x00000, 0x10000, 0x4d24c768 )
  344.     ROM_LOAD( "136075-1.016", 0x10000, 0x10000, 0x12e9b4b7 )
  345. ROM_END
  346.  
  347.  
  348. ROM_START( klax2 )
  349.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  350.     ROM_LOAD_EVEN( "136075.006",   0x00000, 0x10000, 0x05c98fc0 )
  351.     ROM_LOAD_ODD ( "136075.005",   0x00000, 0x10000, 0xd461e1ee )
  352.     ROM_LOAD_EVEN( "136075.008",   0x20000, 0x10000, 0xf1b8e588 )
  353.     ROM_LOAD_ODD ( "136075.007",   0x20000, 0x10000, 0xadbe33a8 )
  354.  
  355.     ROM_REGION( 0x40000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  356.     ROM_LOAD( "136075-2.010", 0x00000, 0x10000, 0x15290a0d )
  357.     ROM_LOAD( "136075-2.012", 0x10000, 0x10000, 0xc0d9eb0f )
  358.     ROM_LOAD( "136075-2.009", 0x20000, 0x10000, 0x6368dbaf )
  359.     ROM_LOAD( "136075-2.011", 0x30000, 0x10000, 0xe83cca91 )
  360.  
  361.     ROM_REGION( 0x20000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  362.     ROM_LOAD( "136075-2.014", 0x00000, 0x10000, 0x5c551e92 )
  363.     ROM_LOAD( "136075-2.013", 0x10000, 0x10000, 0x36764bbc )
  364.  
  365.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM data */
  366.     ROM_LOAD( "136075-1.015", 0x00000, 0x10000, 0x4d24c768 )
  367.     ROM_LOAD( "136075-1.016", 0x10000, 0x10000, 0x12e9b4b7 )
  368. ROM_END
  369.  
  370.  
  371. ROM_START( klax3 )
  372.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  373.     ROM_LOAD_EVEN( "5006",         0x00000, 0x10000, 0x65eb9a31 )
  374.     ROM_LOAD_ODD ( "5005",         0x00000, 0x10000, 0x7be27349 )
  375.     ROM_LOAD_EVEN( "4008",         0x20000, 0x10000, 0xf3c79106 )
  376.     ROM_LOAD_ODD ( "4007",         0x20000, 0x10000, 0xa23cde5d )
  377.  
  378.     ROM_REGION( 0x40000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  379.     ROM_LOAD( "136075-2.010", 0x00000, 0x10000, 0x15290a0d )
  380.     ROM_LOAD( "136075-2.012", 0x10000, 0x10000, 0xc0d9eb0f )
  381.     ROM_LOAD( "136075-2.009", 0x20000, 0x10000, 0x6368dbaf )
  382.     ROM_LOAD( "136075-2.011", 0x30000, 0x10000, 0xe83cca91 )
  383.  
  384.     ROM_REGION( 0x20000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  385.     ROM_LOAD( "136075-2.014", 0x00000, 0x10000, 0x5c551e92 )
  386.     ROM_LOAD( "136075-2.013", 0x10000, 0x10000, 0x36764bbc )
  387.  
  388.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM data */
  389.     ROM_LOAD( "136075-1.015", 0x00000, 0x10000, 0x4d24c768 )
  390.     ROM_LOAD( "136075-1.016", 0x10000, 0x10000, 0x12e9b4b7 )
  391. ROM_END
  392.  
  393.  
  394. ROM_START( klaxj )
  395.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  396.     ROM_LOAD_EVEN( "136075-3.406", 0x00000, 0x10000, 0xab2aa50b )
  397.     ROM_LOAD_ODD ( "136075-3.405", 0x00000, 0x10000, 0x9dc9a590 )
  398.     ROM_LOAD_EVEN( "136075-2.408", 0x20000, 0x10000, 0x89d515ce )
  399.     ROM_LOAD_ODD ( "136075-2.407", 0x20000, 0x10000, 0x48ce4edb )
  400.  
  401.     ROM_REGION( 0x40000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  402.     ROM_LOAD( "136075-2.010", 0x00000, 0x10000, 0x15290a0d )
  403.     ROM_LOAD( "136075-2.012", 0x10000, 0x10000, 0xc0d9eb0f )
  404.     ROM_LOAD( "136075-2.009", 0x20000, 0x10000, 0x6368dbaf )
  405.     ROM_LOAD( "136075-2.011", 0x30000, 0x10000, 0xe83cca91 )
  406.  
  407.     ROM_REGION( 0x20000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  408.     ROM_LOAD( "136075-2.014", 0x00000, 0x10000, 0x5c551e92 )
  409.     ROM_LOAD( "136075-2.013", 0x10000, 0x10000, 0x36764bbc )
  410.  
  411.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM data */
  412.     ROM_LOAD( "136075-1.015", 0x00000, 0x10000, 0x4d24c768 )
  413.     ROM_LOAD( "136075-1.016", 0x10000, 0x10000, 0x12e9b4b7 )
  414. ROM_END
  415.  
  416.  
  417.  
  418. /*************************************
  419.  *
  420.  *    Driver initialization
  421.  *
  422.  *************************************/
  423.  
  424. static void init_klax(void)
  425. {
  426.     atarigen_eeprom_default = NULL;
  427. }
  428.  
  429.  
  430.  
  431. /*************************************
  432.  *
  433.  *    Game driver(s)
  434.  *
  435.  *************************************/
  436.  
  437. GAME( 1989, klax,  0,    klax, klax, klax, ROT0, "Atari Games", "Klax (set 1)" )
  438. GAME( 1989, klax2, klax, klax, klax, klax, ROT0, "Atari Games", "Klax (set 2)" )
  439. GAME( 1989, klax3, klax, klax, klax, klax, ROT0, "Atari Games", "Klax (set 3)" )
  440. GAME( 1989, klaxj, klax, klax, klax, klax, ROT0, "Atari Games", "Klax (Japan)" )
  441.